﻿Imports NearAop

<AddProxyMethod(GetType(Proxy3), HandlerName:="自定义函数")>
Public Class T06_方法代理_指定处理函数名称

    '实例函数
    Public Sub SetValue1(value As Integer)
    End Sub

    '静态函数
    Public Shared Sub SetValue2(value As Integer)
    End Sub

End Class

Class Proxy3

    Public Sub 自定义函数(methodArgs As MethodArgs)
        Dim info = methodArgs.MethodInfo
        Dim staticStr = If(info.IsStatic, "静态", "")
        Console.WriteLine($"进入{staticStr}函数[{info.DeclaringType}.{info.Name}]")
    End Sub

    Public Function 自定义函数(Of T)(methodArgs As MethodArgs, result As T) As T
        Dim info = methodArgs.MethodInfo
        Dim staticStr = If(info.IsStatic, "静态", "")
        Console.WriteLine($"退出{staticStr}函数[{info.DeclaringType}.{info.Name}]")
        Return result
    End Function

End Class